package cn.blb.service.oss.controller;

import cn.blb.common.result.Result;
import cn.blb.service.oss.service.FileService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/oss")
@CrossOrigin
public class FileController {

    private final FileService fileService;

    public FileController(FileService fileService) {
        this.fileService = fileService;
    }

    @PostMapping("/upload/{path}")
    public Result upload(MultipartFile file, @PathVariable String path){
        String url = fileService.upload(file,path);
        return Result.ok().setMessage("上传成功").setData("url",url);
    }


}
